package com.wuwei.elearning.jobcard;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import com.deepoove.poi.template.ElementTemplate;
import org.apache.poi.xwpf.usermodel.*;

import java.util.List;

public class CustomTableRenderPolicy extends LoopRowTableRenderPolicy {

    public CustomTableRenderPolicy() {
    }

    public CustomTableRenderPolicy(boolean onSameLine) {
        super(onSameLine);
    }

    public CustomTableRenderPolicy(String prefix, String suffix) {
        super(prefix, suffix);
    }

    public CustomTableRenderPolicy(String prefix, String suffix, boolean onSameLine) {
        super(prefix, suffix, onSameLine);
    }


    protected void afterloop(XWPFTable table, Object data) {
        System.out.println(table);
        // 获取刚刚渲染的行
        List<XWPFTableRow> rows = table.getRows();
        for (XWPFTableRow row : rows) {
            if (row != null) {
                for (XWPFTableCell cell : row.getTableCells()) {
                    for (XWPFParagraph paragraph : cell.getParagraphs()) {
                        paragraph.setAlignment(ParagraphAlignment.LEFT); // 设置段落左对齐
                    }
                }
            }
        }
    }
}
